package com.atguigu.zy.interview.juc.cas;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Author : Jungle
 * @Description :
 * 1、CAS是什么 ==>compareAndSet
 *      比较并交换
 */
public class CASDemo {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(5);
        System.out.println(atomicInteger.compareAndSet(5, 2019)+"\t current data \t"+atomicInteger.get());
        System.out.println(atomicInteger.compareAndSet(5, 1024)+"\t current data \t"+atomicInteger.get());
        atomicInteger.getAndIncrement();
    }
}
